package com.zn.controller;

import com.github.pagehelper.PageHelper;
import com.zn.common.constants.Constants;
import com.zn.common.resp.ApiResult;
import com.zn.common.utils.FileUtils;
import com.zn.dto.VeiReportDTO;
import com.zn.dto.VeiReportInfoDTO;
import com.zn.dto.VeiReportInfoDTO2;
import com.zn.pojo.*;
import com.zn.services.UserService;
import com.zn.services.VeiReportInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.log4j.Log4j2;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
import java.util.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

/**
 * @author xyl
 * @create 2020/7/1 10:15
 * @desc
 **/
@Api(tags = "用户操作 , 用户权限")
@Log4j2
@RestController
@RequestMapping("user")
public class UserController {
    @Autowired
    private VeiReportInfoService veiReportInfoService;

    @Autowired
    private UserService userService;

    @GetMapping("test")
    public ApiResult test() {
        return new ApiResult(200, "请求成功!");
    }

    @ApiOperation("上传文档接口 , 需要在请求头中携带用户id --> uid , 图片都要转成base64格式")
    @PostMapping("submit-report")
    public ApiResult submit(@RequestBody VeiReportInfo info, HttpServletRequest request, @RequestParam(value = "type", required = false) Integer type) {
        info.setCreateTime(new Date());
        base64toImage1(info);
        if (info.getReportId() != null && null == type) {
            //todo 保存的报告 提交 , 修改状态即可
            if (!StringUtils.isEmpty(info.getReportNumber())) {
                boolean con = veiReportInfoService.checkReportNumberRepetition(info.getReportNumber());
                if (con) {
                    return new ApiResult(200, "报告编号:" + info.getReportNumber() + ",有重复!无法提交");
                }
            }
            veiReportInfoService.saveVeiReportInfo(info, Integer.valueOf(request.getHeader("uid")));
            int count = veiReportInfoService.modifyReportStatus(info.getReportId(), Integer.valueOf(request.getHeader("uid")), Constants.REPORT_STATUS1);
            if (count != 0) {
                log.info("提交成功!");
            }
            return new ApiResult(200, "请求成功!");
        } else if (info.getReportId() != null && type == 0) {
            //todo 说明用户保存后, 再次进行保存
            int count = veiReportInfoService.saveVeiReportInfo(info, Integer.valueOf(request.getHeader("uid")));
            if (count != 0) {
                log.info("保存成功!");
            }
            return new ApiResult(200, "请求成功!");
        }
        if (!StringUtils.isEmpty(info.getReportNumber()) && (type == null || Constants.REPORT_STATUS1 == type)) {
            boolean con = veiReportInfoService.checkReportNumberRepetition(info.getReportNumber());
            if (con) {
                return new ApiResult(200, "报告编号:" + info.getReportNumber() + ",有重复!无法提交");
            }
        }
        info.setUuid(UUID.randomUUID().toString());
        int count = veiReportInfoService.addVeiReportInfo(type, info, Integer.valueOf(request.getHeader("uid")));
        if (count == 0) {
            log.info("----------插入失败-------");
            return new ApiResult(9001, "检测报告上传失败!");
        }
        return new ApiResult(200, "请求成功!");
    }


    @ApiOperation("上传文档接口 , 需要在请求头中携带用户id --> uid , 图片都要转成base64格式")
    @PostMapping("submit-report2")
    public ApiResult submit2(@RequestBody VeiReportInfo2 info, HttpServletRequest request) {
        base64toImage2(info);
        info.setCreateTime(new Date());
        boolean con = veiReportInfoService.checkReport2NumberRepetition(info.getReportNumber());
        if (con) {
            return new ApiResult(200, "报告编号:" + info.getReportNumber() + ",有重复!无法提交");
        }
        if (null == info.getReport2Id()) {
            int count = veiReportInfoService.addVeiReport2Info(info, Integer.valueOf(request.getHeader("uid")), Constants.REPORT_STATUS1);
            if (count == 0) {
                log.info("----------插入失败-------");
                return new ApiResult(9001, "检测报告上传失败!");
            }
        } else {
            veiReportInfoService.modifyReportInfo2(info);
            veiReportInfoService.modifyReport2Status(info.getReport2Id(), Constants.REPORT_STATUS1);
        }
        return new ApiResult(200, "检测报告上传成功!");
    }

    @PostMapping("/report2/modify-status")
    public ApiResult modifyStatus2(@RequestParam Integer rid, @RequestParam Integer status) {
        int count = veiReportInfoService.modifyReport2Status(rid, status);
        return new ApiResult();
    }

    @PostMapping("/report1/modify-status")
    public ApiResult modifyStatus1(@RequestParam Integer rid, @RequestParam Integer status, HttpServletRequest request) {
        Integer uid = Integer.valueOf(request.getHeader("uid"));
        int count = veiReportInfoService.modifyReportStatus(rid, uid, status);
        return new ApiResult();
    }

    @PostMapping("save-report2")
    public ApiResult save_report2(@RequestBody VeiReportInfo2 info2, HttpServletRequest request) {
        ApiResult result = new ApiResult();
        Integer uid = Integer.valueOf(request.getHeader("uid"));
        base64toImage2(info2);
        int count;
        if (null == info2.getReport2Id()) {
            info2.setCreateTime(new Date());
            count = veiReportInfoService.addVeiReport2Info(info2, uid, Constants.REPORT_STATUS0);
        } else {
            count = veiReportInfoService.modifyReportInfo2(info2);
        }
        if (count != 1) {
            return new ApiResult(500, "操作失败");
        }
        result.setData(info2.getReport2Id());
        return result;
    }

    @ApiOperation("修改报告数据")
    @PostMapping("modify-report")
    public ApiResult modifyReport(@RequestBody VeiReportInfo info, HttpServletRequest request) {
        Integer role = (Integer) request.getSession().getAttribute(request.getSession().getId());
        Integer uid = Integer.valueOf(request.getHeader("uid"));
        ApiResult result = veiReportInfoService.modifyReportInfo(role, uid, info);
        return result;
    }

    @ApiOperation("修改报告数据")
    @PostMapping("modify-report2")
    public ApiResult modifyReport2(@RequestBody VeiReportInfo2 info, HttpServletRequest request) {
        Integer role = (Integer) request.getSession().getAttribute(request.getSession().getId());
        Integer uid = Integer.valueOf(request.getHeader("uid"));
        ApiResult result = veiReportInfoService.modifyReport2Info(role, uid, info);
        return result;
    }

    @GetMapping("view_report2")
    public ModelAndView viewReport2() {
        ModelAndView mav = new ModelAndView("user_view/view_report2");
        return mav;
    }

    //todo
    @ApiOperation("上传平顶山文档接口 , 需要在请求头中携带用户id --> uid , todo 未完成")
    @PostMapping("submit-PDS-report")
    public ApiResult submitPDSReport(@RequestBody PDSReportInfo info, HttpServletRequest request) {
        String uid = request.getHeader("uid");
        return new ApiResult(200, "检测报告上传成功!");
    }

    @ApiOperation("上传省平台文档接口 , 需要在请求头中携带用户id --> uid , todo 未完成")
    @PostMapping("submit-SPT-report")
    public ApiResult submitSPTReport(@RequestBody SPTReportInfo info, HttpServletRequest request) {
        String uid = request.getHeader("uid");
        return new ApiResult(200, "检测报告上传成功!");
    }

    @ApiOperation("更新用户密码, 请求头中需要携带用户id --> uid=")
    @PostMapping("update-pwd")
    public ApiResult updatePassword(HttpServletRequest request, @RequestParam String password) {
        Integer uid = Integer.valueOf(request.getHeader("uid"));
        int count = userService.updatePassword(uid, password);
        if (count != 1) {
            return new ApiResult(500, "修改密码失败!");
        }
        return new ApiResult();
    }

    @GetMapping("get-report")
    public ApiResult getReport(HttpServletRequest request,
                               @RequestParam(value = "status", required = false) Integer status) {
        ApiResult result = new ApiResult();
        Integer uid = Integer.valueOf(request.getHeader("uid"));
        List<VeiReportInfoDTO> lists;
        if (status == null) {
            //mybaitys 中写的 status > 0  排除了 非保存的状态
            lists = veiReportInfoService.getUserReportByUid(uid);
        } else {
            lists = veiReportInfoService.getUserReportByStatus(uid, status);
        }
        result.setData(lists);
        return result;
    }

    @GetMapping("get-report2")
    public ApiResult getReport2(HttpServletRequest request,
                                @RequestParam(value = "status", required = false) Integer status) {
        ApiResult result = new ApiResult();
        Integer uid = Integer.valueOf(request.getHeader("uid"));
        List<VeiReportInfoDTO2> lists;
        if (Constants.HEDA_USER_ID.equals(uid) && status != null && status == 0) {
            //查询保存的状态
            lists = veiReportInfoService.hedaGetReport(uid, Constants.HEDA_USER_SON_ID1, Constants.HEDA_USER_SON_ID2);
            result.setData(lists);
            return result;
        }
        if (status == null) {
            //mybaitys 中写的 status > 0  排除了 非保存的状态
            lists = veiReportInfoService.getUserReport2ByUid(uid);
        } else {
            lists = veiReportInfoService.getUserReport2ByStatus(uid, status);
        }
        result.setData(lists);
        return result;
    }

    @GetMapping("report-error-info")
    public ApiResult reportErrorInfo(@RequestParam("rid") Integer rid, @RequestParam("status") Integer status) {
        ApiResult result = new ApiResult();
        String errorInfo = veiReportInfoService.getReportErrorInfo(rid, status);
        result.setData(errorInfo);
        return result;
    }

    @GetMapping("report2-error-info")
    public ApiResult report2ErrorInfo(@RequestParam("rid") Integer rid, @RequestParam("status") Integer status) {
        ApiResult result = new ApiResult();
        String errorInfo = veiReportInfoService.getReport2ErrorInfo(rid, status);
        result.setData(errorInfo);
        return result;
    }

    @GetMapping("remove-reprot1")
    public ApiResult removeReprot1(@RequestParam("rid") Integer rid, HttpServletRequest request) {
        ApiResult apiResult = new ApiResult();
        Integer uid = Integer.valueOf(request.getHeader("uid"));
        int count = veiReportInfoService.removeReport1(rid, uid);
        return apiResult;
    }

    @GetMapping("remove-reprot2")
    public ApiResult removeReprot2(@RequestParam("rid") Integer rid, HttpServletRequest request) {
        ApiResult apiResult = new ApiResult();
        Integer uid = Integer.valueOf(request.getHeader("uid"));
        int count = veiReportInfoService.removeReport2(rid, uid);
        return apiResult;
    }

    @ApiOperation("公共接口 , 根据rid 获取唯一报告")
    @GetMapping("get")
    public ApiResult getReportByRid(@RequestParam("rid") Integer rid) {
        ApiResult result = new ApiResult();
        VeiReportInfo reportInfo = veiReportInfoService.getUserReportByRid(rid);
        load_image1(reportInfo);
        result.setData(reportInfo);
        return result;
    }

    @ApiOperation("公共接口 , 根据rid 获取唯一保存的报告")
    @GetMapping("get-save-report")
    public ModelAndView getSaveReport(@RequestParam("rid") Integer rid,
                                      @RequestParam("status") Integer status,
                                      @RequestParam("ten") Integer ten,
                                      HttpServletRequest request) {
        ModelAndView modelAndView = new ModelAndView("user_view/submit_report");
        VeiReportInfo reportInfo = veiReportInfoService.getUserReportByRid(rid);
        ReportVerifyInfo verifyInfo = veiReportInfoService.getVeiReportStatusByRid(rid);
        UserRoleRelation curUser = userService.findUserAuthByUid(ten);
        if (curUser.getRoleId() == Constants.ROLE_SYSTEM_BOSS) {
            request.setAttribute("verify_status", "modify");
            modelAndView.addObject("data", reportInfo);
            load_image1(reportInfo);
            return modelAndView;
        }
        if (status.equals(verifyInfo.getStatus()) && (status == 0 || status == 1 || status == 3 || status == 5) && curUser.getUserId() == verifyInfo.getUserId()) {
            if (status == 0) {
                request.setAttribute("verify_status", "save");
            } else {
                request.setAttribute("verify_status", "modify");
            }
        } else {
            return null;
        }
        load_image1(reportInfo);
        modelAndView.addObject("data", reportInfo);
        return modelAndView;
    }

    @ApiOperation("公共接口 , 根据rid 获取唯一保存的报告")
    @GetMapping("get-save-report2")
    public ModelAndView getSaveReport2(@RequestParam("rid") Integer rid,
                                       @RequestParam("status") Integer status,
                                       @RequestParam("ten") Integer ten,
                                       HttpServletRequest request) {
        ModelAndView modelAndView = new ModelAndView("user_view/submit_report2");
        VeiReportInfo2 reportInfo = veiReportInfoService.getUserReport2ByRid(rid);
        ReportVerifyInfo2 verifyInfo = veiReportInfoService.getVeiReport2StatusByRid(rid);
        UserRoleRelation curUser = userService.findUserAuthByUid(ten);
        if (curUser.getRoleId() == Constants.ROLE_SYSTEM_BOSS) {
            request.setAttribute("verify_status", "modify");
            modelAndView.addObject("data", reportInfo);
            load_image2(reportInfo);
            return modelAndView;
        }
        if (status.equals(verifyInfo.getStatus()) && (status == 0 || status == 1 || status == 3 || status == 5) && curUser.getUserId() == verifyInfo.getUserId()) {
            if (status == 0) {
                request.setAttribute("verify_status", "save");
            } else {
                request.setAttribute("verify_status", "modify");
            }
        } else {
            return null;
        }
        load_image2(reportInfo);
        modelAndView.addObject("data", reportInfo);
        return modelAndView;
    }

    @GetMapping("get2")
    public ApiResult get2(@RequestParam("rid") Integer rid, HttpServletRequest request) {
        //todo 判断是不是自己的报告
        ApiResult result = new ApiResult();
        VeiReportInfo2 veiReportInfo2 = veiReportInfoService.getReport2ByRid(rid);
        load_image2(veiReportInfo2);
//        ReportVerifyInfo2 verifyInfo2 = veiReportInfoService.getVeiReport2StatusByRid(rid);
//        request.setAttribute("status",verifyInfo2.getStatus());
        result.setData(veiReportInfo2);
        return result;
    }

    @GetMapping("/search/vehicle")
    public ModelAndView searchVehicleHTML(HttpServletRequest request) {
        ModelAndView mav = new ModelAndView("user_view/search_vehicle");
        mav.addObject("role", request.getSession().getAttribute(request.getSession().getId()));
        return mav;
    }

    /**
     * 下载原始记录
     *
     * @param rid
     * @param response
     */
    @GetMapping("export_ysjl_report1_excel")
    public void exportYsjlReportExcel2(@RequestParam("rid") Integer rid, HttpServletResponse response) {
        VeiReportInfo reportInfo = veiReportInfoService.getUserReportByRid(rid);
        try {
            XSSFWorkbook wb = veiReportInfoService.exportYsjlReportExcel(reportInfo, response);
            try {
                response.reset();
                response.setContentType("application/vnd.ms-excel");
                response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(reportInfo.getReportNumber() + ".xlsx", "utf-8"));
                ServletOutputStream outputStream = response.getOutputStream();
                wb.write(outputStream);
                outputStream.flush();
                outputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 打包下载报告
     *
     * @param request
     * @param response
     */
    @GetMapping("/export_ysjl_report1_excel/all")
    public void exportYsjlReport2ExcelAll(HttpServletRequest request, HttpServletResponse response) {
        Integer uid = (Integer) request.getSession().getAttribute("userId");
        ZipOutputStream zos = null;
        try {
            zos = new ZipOutputStream(response.getOutputStream());
            if (!ObjectUtils.isEmpty(uid)) {
                List<VeiReportInfo> reports = veiReportInfoService.getReportByUId(uid);
                for (VeiReportInfo report : reports) {
                    //获取文件流
                    InputStream input = workbookToInpustream(veiReportInfoService.exportYsjlReportExcel(report, response));
                    //压缩文件名称 设置ZipEntry对象
                    zos.putNextEntry(new ZipEntry(report.getReportNumber() + ".xlsx"));
                    int temp;
                    // 读取内容
                    while ((temp = input.read()) != -1) {
                        // 压缩输出
                        zos.write(temp);
                    }
                    input.close();
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                zos.flush();
                zos.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    @GetMapping("/export/report1/all")
    public void exportReport1All(HttpServletResponse response) {
        ZipOutputStream zos = null;
        try {
            zos = new ZipOutputStream(response.getOutputStream());
            List<VeiReportInfo> reports = veiReportInfoService.getReport1ByStatus(Constants.REPORT_STATUS6);
            int count = 1;
            for (VeiReportInfo report : reports) {
                System.out.println(reports.size() + "-----" + count);
                //获取文件流
                InputStream input = workbookToInpustream(veiReportInfoService.exportReportExcel(report));
                //压缩文件名称 设置ZipEntry对象
                zos.putNextEntry(new ZipEntry((count++) + "_" + report.getReportNumber() + ".xlsx"));
                int temp;
                // 读取内容
                while ((temp = input.read()) != -1) {
                    // 压缩输出
                    zos.write(temp);
                }
                input.close();
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                zos.flush();
                zos.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    @GetMapping("/export/report2/all")
    public void exportReport2All(HttpServletResponse response) {
        ZipOutputStream zos = null;
        try {
            zos = new ZipOutputStream(response.getOutputStream());
            List<VeiReportInfo2> reports = veiReportInfoService.getReport2ByStatus(Constants.REPORT_STATUS6);
            System.out.println(reports.size());
            int count = 1;
            for (VeiReportInfo2 report : reports) {
                System.out.println(reports.size() + "-----" + count);
                //获取文件流
                InputStream input = workbookToInpustream(veiReportInfoService.exportReport2Excel(report));
                //压缩文件名称 设置ZipEntry对象
                zos.putNextEntry(new ZipEntry((count++) + "_" + report.getReportNumber() + ".xlsx"));
                int temp;
                // 读取内容
                while ((temp = input.read()) != -1) {
                    // 压缩输出
                    zos.write(temp);
                }
                input.close();
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                zos.flush();
                zos.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }


    public static InputStream workbookToInpustream(XSSFWorkbook workbook) {
        try {
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            workbook.write(bos);
            byte[] barray = bos.toByteArray();
            return new ByteArrayInputStream(barray);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }


    private void load_image2(VeiReportInfo2 reportInfo) {
        if (null == reportInfo) {
            return;
        }
        if (!StringUtils.isEmpty(reportInfo.getPic1())) {
            reportInfo.setPic1(Constants.REPORT_IMG_VIRTUAL_UTL + reportInfo.getPic1());
        }
        if (!StringUtils.isEmpty(reportInfo.getPic2())) {
            reportInfo.setPic2(Constants.REPORT_IMG_VIRTUAL_UTL + reportInfo.getPic2());
        }
        if (!StringUtils.isEmpty(reportInfo.getPic3())) {
            reportInfo.setPic3(Constants.REPORT_IMG_VIRTUAL_UTL + reportInfo.getPic3());
        }
        if (!StringUtils.isEmpty(reportInfo.getPic4())) {
            reportInfo.setPic4(Constants.REPORT_IMG_VIRTUAL_UTL + reportInfo.getPic4());
        }
        if (!StringUtils.isEmpty(reportInfo.getPic5())) {
            reportInfo.setPic5(Constants.REPORT_IMG_VIRTUAL_UTL + reportInfo.getPic5());
        }
        if (!StringUtils.isEmpty(reportInfo.getPic6())) {
            reportInfo.setPic6(Constants.REPORT_IMG_VIRTUAL_UTL + reportInfo.getPic6());
        }
        if (!StringUtils.isEmpty(reportInfo.getPic7())) {
            reportInfo.setPic7(Constants.REPORT_IMG_VIRTUAL_UTL + reportInfo.getPic7());
        }
        if (!StringUtils.isEmpty(reportInfo.getPic8())) {
            reportInfo.setPic8(Constants.REPORT_IMG_VIRTUAL_UTL + reportInfo.getPic8());
        }
        if (!StringUtils.isEmpty(reportInfo.getPic9())) {
            reportInfo.setPic9(Constants.REPORT_IMG_VIRTUAL_UTL + reportInfo.getPic9());
        }
        if (!StringUtils.isEmpty(reportInfo.getPic10())) {
            reportInfo.setPic10(Constants.REPORT_IMG_VIRTUAL_UTL + reportInfo.getPic10());
        }
    }

    private void load_image1(VeiReportInfo reportInfo) {
        if (null == reportInfo) {
            return;
        }
        if (!StringUtils.isEmpty(reportInfo.getFpic1())) {
            reportInfo.setFpic1(Constants.REPORT_IMG_VIRTUAL_UTL + reportInfo.getFpic1());
        }
        if (!StringUtils.isEmpty(reportInfo.getFpic2())) {
            reportInfo.setFpic2(Constants.REPORT_IMG_VIRTUAL_UTL + reportInfo.getFpic2());
        }
        if (!StringUtils.isEmpty(reportInfo.getFpic3())) {
            reportInfo.setFpic3(Constants.REPORT_IMG_VIRTUAL_UTL + reportInfo.getFpic3());
        }
        if (!StringUtils.isEmpty(reportInfo.getFpic4())) {
            reportInfo.setFpic4(Constants.REPORT_IMG_VIRTUAL_UTL + reportInfo.getFpic4());
        }
        if (!StringUtils.isEmpty(reportInfo.getFpic5())) {
            reportInfo.setFpic5(Constants.REPORT_IMG_VIRTUAL_UTL + reportInfo.getFpic5());
        }
        if (!StringUtils.isEmpty(reportInfo.getFpic6())) {
            reportInfo.setFpic6(Constants.REPORT_IMG_VIRTUAL_UTL + reportInfo.getFpic6());
        }
        if (!StringUtils.isEmpty(reportInfo.getFpic7())) {
            reportInfo.setFpic7(Constants.REPORT_IMG_VIRTUAL_UTL + reportInfo.getFpic7());
        }
        if (!StringUtils.isEmpty(reportInfo.getFpic8())) {
            reportInfo.setFpic8(Constants.REPORT_IMG_VIRTUAL_UTL + reportInfo.getFpic8());
        }
        if (!StringUtils.isEmpty(reportInfo.getFpic9())) {
            reportInfo.setFpic9(Constants.REPORT_IMG_VIRTUAL_UTL + reportInfo.getFpic9());
        }
        if (!StringUtils.isEmpty(reportInfo.getFpic10())) {
            reportInfo.setFpic10(Constants.REPORT_IMG_VIRTUAL_UTL + reportInfo.getFpic10());
        }
    }

    private void base64toImage1(VeiReportInfo info) {
        info.setFpic1(FileUtils.Base64ToImage(info.getFpic1()));
        info.setFpic2(FileUtils.Base64ToImage(info.getFpic2()));
        info.setFpic3(FileUtils.Base64ToImage(info.getFpic3()));
        info.setFpic4(FileUtils.Base64ToImage(info.getFpic4()));
        info.setFpic5(FileUtils.Base64ToImage(info.getFpic5()));
        info.setFpic6(FileUtils.Base64ToImage(info.getFpic6()));
        info.setFpic7(FileUtils.Base64ToImage(info.getFpic7()));
        info.setFpic8(FileUtils.Base64ToImage(info.getFpic8()));
        info.setFpic9(FileUtils.Base64ToImage(info.getFpic9()));
        info.setFpic10(FileUtils.Base64ToImage(info.getFpic10()));
    }

    private void base64toImage2(VeiReportInfo2 info) {
        info.setPic1(FileUtils.Base64ToImage(info.getPic1()));
        info.setPic2(FileUtils.Base64ToImage(info.getPic2()));
        info.setPic3(FileUtils.Base64ToImage(info.getPic3()));
        info.setPic4(FileUtils.Base64ToImage(info.getPic4()));
        info.setPic5(FileUtils.Base64ToImage(info.getPic5()));
        info.setPic6(FileUtils.Base64ToImage(info.getPic6()));
        info.setPic7(FileUtils.Base64ToImage(info.getPic7()));
        info.setPic8(FileUtils.Base64ToImage(info.getPic8()));
        info.setPic9(FileUtils.Base64ToImage(info.getPic9()));
        info.setPic10(FileUtils.Base64ToImage(info.getPic10()));
    }
}
